let total = 10;

let params = {
    pagenum: 1,
    pagesize: 4,
  }
let arr=[];
function shuangxin () {
    $.ajax ({
        type: 'GET',
        data: params,
        url: 'http://localhost:8888/api/articles',
        success: function(res) {
            // console.log(res);
            if(total !== 0 && arr.length >=total) {
                return layer.msg('没有更多数据了')
            } else {
                
                res.data.forEach( item => {
                    arr.push(
                        `
                    <div class="item">
                     <h4>
                        <a href="./detail.html?id=${item.id}">${item.title}</a>
                     </h4>
                        <p class="meta">
                        <span>${item.pub_date}</span>
                        <a href="javascript:;" class="wechat"></a>
                        <a href="javascript:;" class="weibo"></a>
                        </p>
                        <p class="brief">${item.content}</p>
                    </div>
                    `
                    )
                });
                // $('.kr_news_list').html(str)
                $('.kr_news_list').append(arr.join(''))

            }
            
        }
    })
}
shuangxin ();



$('.kr_more').on('click', function () {
    params.pagenum += 1;
    shuangxin ();

})
